<?php
namespace app_supplier\assets;
use Yii;
use yii\web\AssetBundle;
use yii\web\View;
class SuppAssets extends AssetBundle
{
    public $basePath = "@webroot";#物理路劲
    public $baseUrl = "@web";#url根路径

    public $css = [
        'css/basemod.css',
        'css/button.css',
        'css/common.css',
//        'css/form.css',
        //'css/invoice.css',
        'css/jquery.webui-popover.min.css',
        'css/stylesheet.css',
        'layer/skin/default/layer.css',
        'jquery-ui/themes/jquery-ui-1.8.16.custom.css',
    ];
    public $js = [
        'js/jquery-1.7.1.min.js',
        'js/SuperSlide.2.1.js',
        'js/superfish/js/superfish.js',
        //'js/superfish/js/hoverIntent.js',

        'jquery-ui/js/jquery-ui-1.8.9.custom.min.js',
        'jquery-ui/js/ui.datepicker-zh-CN.js',
        'layer/layer.js',
    ];
    public $depends = [
        'yii\web\YiiAsset',
        //'yii\bootstrap\BootstrapAsset',
    ];
    public $jsOptions = [
        'position' =>View::POS_HEAD
    ];
    /**添加css文件
     * @param $view
     * @param $cssFile
     */
    public static function addCss($view, $cssFile)
    {
        $view->registerCssFile($cssFile, [
            SuppAssets::className(),
            'depends'=>'app_supplier\assets\SuppAssets'
        ]);
    }

    /**添加js文件
     * @param $view
     * @param $jsFile
     */
    public static function addScript($view, $jsFile)
    {
        $view->registerJsFile($jsFile, [
            SuppAssets::className(),
            'depends'=>'app_supplier\assets\SuppAssets'
        ]);
    }

    #----数组方式添加css与js
    /**
     * 组合添加css
     * @param $view
     * @param array $cssFile
     */
    public static function addArrayCss($view, $cssFile = [])
    {
        if (!empty($cssFile) && is_array($cssFile)) {
            foreach ($cssFile as $css) {
                $view->registerCssFile($css, [
                    SuppAssets::className(),
                    'depends'=>'app_supplier\assets\SuppAssets'
                ]);
            }
        }
    }

    /**
     * 组合添加js
     * @param $view
     * @param array $jsFile
     */
    public static function addArrayScript($view, $jsFile = [] ,$position=View::POS_END)
    {
        if (!empty($jsFile) && is_array($jsFile)) {
            foreach ($jsFile as $js) {
                $view->registerJsFile($js, [
                    SuppAssets::className(),
                    'depends'=>'app_supplier\assets\SuppAssets',
                    'position'=>$position
                ]);
            }
        }
    }

}